package com.thot.timyag.core.support;

import com.thot.timyag.core.ApplicationContextProvider;
import com.thot.timyag.core.HotDeployContext;
import org.mybatis.spring.mapper.MapperFactoryBean;


/**
 * @author yangjf
 * @time 2019-05-13 15:26
 */
public class SelfMapperFactoryBean extends MapperFactoryBean {

    private String mapperInterfaceStr;

    public SelfMapperFactoryBean() {
    }

    public SelfMapperFactoryBean(String mapperInterfaceStr) {
        this.mapperInterfaceStr = mapperInterfaceStr;
    }

    @Override
    protected void checkDaoConfig() {
        HotDeployContext context = ApplicationContextProvider.getBean(HotDeployContext.class);
        try {
            this.setMapperInterface(context.getClassLoader().loadClass(this.mapperInterfaceStr));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        super.checkDaoConfig();

    }


}
